﻿using Api.Application.Command.City;
using Api.Application.Command.Province;
using Api.Application.Command.Region;
using Api.Application.Command.User;
using Api.DTO;
using Common.Architecture.Common;
using ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Api.Controllers
{
    /// <summary>
    /// 控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private readonly IMediator mediator;

        public UserController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<LoginDTO>> LoginUser([FromQuery]LoginUserCommand request)
        {

            //string numberStr = "123";
            //int number =numberStr.ToInt32();

            //string shenid = "130434200610234842".GetBirthByCarId();

            

            return mediator.Send(request);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddUser(AddUserCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<UserDTO>> ShowUser([FromQuery]ShowUserCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<int>> DelUser([FromQuery]DelUserCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdateUser(UpdateUserCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取省份接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<ProvinceDTO>> ShowProvince([FromQuery]ShowProvinceCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取县接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<RegionDTO>> ShowRegion([FromQuery]ShowRegionCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取市接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<CityDTO>> ShowCity([FromQuery]ShowCityCommand request)
        {
            return mediator.Send(request);  
        }
        /// <summary>
        /// 根据部门id查用户
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<UserDTO>> GetDel([FromQuery]GetDelCommand request)
        {
            return mediator.Send(request);
        }


















    }
}
